﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using RM.Entities.Data;
using RM.Entities;

namespace RM.Web.Services
{
    
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class RMServices:IQuestionService,ITestService,ILogService,ICandidateService
    {
        #region Testservice Members
        
        public IList<Test> GetAll()
        {
            TestManager testManager = new TestManager();
            return testManager.GetAll<Test>("Id");
        }


        public void Save(RM.Entities.Test test)
        {
            TestManager testManager = new TestManager();
            testManager.Save<Test>(test);
        }

        public void Update(RM.Entities.Test test)
        {
            TestManager testManager = new TestManager();
            testManager.Update<Test>(test);
        }

        public Test GetById(int Id)
        {
            TestManager testManager = new TestManager();
            return testManager.GetById<Test>(Id);

        }

        #endregion

        #region Question Members

        QuestionManager manager = null;

        IList<Question> IQuestionService.GetAll()
        {
            manager = new QuestionManager();
            return manager.GetAll<Question>("Experience");
        }


        public IList<Question> GetAllBySearch(string searchString)
        {
            manager = new QuestionManager();
            return manager.GetAllBySearch(searchString);
        }


        Question IQuestionService.GetById(int Id)
        {
            manager = new QuestionManager();
            return manager.GetById<Question>(Id);
        }

        public void Save(Question question)
        {
            manager = new QuestionManager();
            manager.Save<Question>(question);
        }

        public void Update(Question question)
        {
            manager = new QuestionManager();
            manager.Update<Question>(question);
        }

        #endregion

        #region ILogService Members

        IList<RM.Entities.OperationLog> ILogService.GetAll()
        {
            LogManager logManager = new LogManager();
            return logManager.GetAll<OperationLog>("Entity");
        }

        //public IList<RM.Entities.OperationLog> GetAllBySearch(string searchString)
        //{
        //    LogManager logManager = new LogManager();
        //    logManager.GetAll<OperationLog>(Id);

        //}

        public void Save(RM.Entities.OperationLog log)
        {
            LogManager logManager = new LogManager();
            logManager.Save<OperationLog>(log);
        }

        public void Update(RM.Entities.OperationLog log)
        {
            LogManager logManager = new LogManager();
            logManager.Update<OperationLog>(log);

        }

        RM.Entities.OperationLog ILogService.GetById(int Id)
        {
            LogManager logManager = new LogManager();
            return logManager.GetById<OperationLog>(Id);

        }

        #endregion

        #region ICandidateService Members

        IList<Candidate> ICandidateService.GetAll()
        {
            CandidateManager candidateManager = new CandidateManager();
            return candidateManager.GetAll<Candidate>("FirstName");
        }

        public void Save(Candidate candidate)
        {
            CandidateManager candidateManager = new CandidateManager();
            candidateManager.Save<Candidate>(candidate);
        }

        public void Update(Candidate candidate)
        {
            CandidateManager candidateManager = new CandidateManager();
            candidateManager.Update<Candidate>(candidate);
        }

        IList<Candidate> ICandidateService.GetAllBySearch(string searchString)
        {
            CandidateManager candidateManager = new CandidateManager();
            return candidateManager.GetAllBySearch(searchString);
        }

        Candidate ICandidateService.GetById(int candidateId)
        {
            CandidateManager candidateManager = new CandidateManager();
            return candidateManager.GetById<Candidate>(candidateId);
        }

        #endregion

        #region ITestService Members


        IList<Test> ITestService.GetAllBySearch(string searchString)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
